package com.eyolas.passwordmanager.base;

import android.os.Bundle;
import com.eyolas.ormlitesherlock.android.apptools.OrmLiteSherlockActivity;
import com.eyolas.passwordmanager.manager.DatabaseHelper;
import com.eyolas.passwordmanager.utils.StringUtils;

/**
 * Classe de base pour les "Activity"
 * Ajoute la gestion du mot de passe dans le cycle de vie
 * @author Eyolas
 * @date 24 mai 2012
 */
public class PasswordManagerBaseActivity extends OrmLiteSherlockActivity<DatabaseHelper>{
	protected String _key;
	protected Boolean setMenu = true;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		if (_key == null && getIntent().getStringExtra("password") != null && StringUtils.isNotBlank(getIntent().getStringExtra("password"))) {
			_key = getIntent().getStringExtra("password");
		}
	}
	
	@Override
	public void onSaveInstanceState(Bundle outState) {
		if (_key != null)
			outState.putString("password", _key);
		super.onSaveInstanceState(outState);
	}

	@Override
	public void onRestoreInstanceState(Bundle savedInstanceState) {
		super.onRestoreInstanceState(savedInstanceState);
		_key = savedInstanceState.getString("password");
	}
}
